package com.bit.strongbaby;


import android.net.Uri;
import android.os.Bundle;
import android.provider.MediaStore;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;

public class KeyActivity extends Activity {
	private int TAKE_CAMERA = 1;					
	private int TAKE_GALLERY = 2;	
	Uri currImageURI = null;
	String st = null;
	
	TextView tv2;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_key);
		
		tv2 = (TextView)this.findViewById(R.id.tvv);
		
		
		findViewById(R.id.key_camera).setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
			
				Intent intent = new Intent();

				intent.setAction(MediaStore.ACTION_IMAGE_CAPTURE);

				startActivityForResult(intent, TAKE_CAMERA);

			}
		});
		
		findViewById(R.id.key_gallery).setOnClickListener(new View.OnClickListener() {
			
			public void onClick(View v) {
				
				Intent intent = new Intent();
				
				intent.setAction(Intent.ACTION_GET_CONTENT);
				
				intent.setType("image/*");
				
				startActivityForResult(intent, TAKE_GALLERY);

			}

		});
		findViewById(R.id.key_gra).setOnClickListener(new OnClickListener() {
			public void onClick(View v) {
				Intent intent = new Intent(getBaseContext(), GraphMainActivity.class);
				intent.putExtra("key", KeyMeasureActivity.ste);
				startActivity(intent);
				
			}
		});
		
		
	}
	
	@Override

	protected void onActivityResult(int requestCode, int resultCode, Intent data) {

		if(resultCode == RESULT_OK){

			if(requestCode == TAKE_CAMERA){

				currImageURI = data.getData();
				st = currImageURI.toString();
				
				Intent intent1 = new Intent(KeyActivity.this, KeyMeasureActivity.class);
				intent1.putExtra("aaa", st);			
				startActivity(intent1); 
				setContentView(R.layout.activity_key_measure);
				finish();

			}else if(requestCode == TAKE_GALLERY){

				currImageURI = data.getData();
				st = currImageURI.toString();
			
				Intent intent1 = new Intent(KeyActivity.this, KeyMeasureActivity.class);
				intent1.putExtra("aaa", st);			
				startActivity(intent1); 
				setContentView(R.layout.activity_key_measure);
				finish();


			}

		}
	}


	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.key, menu);
		return true;
	}

}
